
/** 表格表头 */
export const tableColumns = (t: (msg:string)=>string) => ([
  {
    prop: 'username',
    label: '用户信息',
    width: 220,
    fixed: 'left'
  },
  {
    prop: 'store_name',
    label: '归属门店',
    minWidth: 100,
  },
  {
    prop: 'daoke_times',
    label: '到课次数',
    minWidth: 100,
  },
  {
    prop: 'qun_total',
    label: '在群状态',
    minWidth: 100,
    format:(val: any) => {
      return '未知'
      return val>0 ?'已加群':'未加群'
    }
  },
  {
    prop: 'relation_total',
    label: '好友状态',
    minWidth: 100,
    format:(val: any) => {
      return '未知'
      return val>0 ?'已加好友':'未加好友'
    }
  },
  {
    prop: 'wanbo_times',
    label: '完课次数',
    minWidth: 100,
  },
  {
    prop: 'money',
    label: '红包总额',
    minWidth: 100,
  },
  {
    prop: 'jifen',
    label: '积分数量',
    minWidth: 100,
  },
  {
    prop: 'time_length',
    label: '上课时长',
    minWidth: 100,
    format: (val:number) => {
      const m = parseInt(val / 60 + '')
      const s = val % 60
      return `${m}分${s}秒`
    }
  },
  {
    prop: 'mobile',
    label: '手机号码',
    minWidth: 100,
  },
  // {
  //   prop: 'action',
  //   label:  t('table.operation'),
  //   width: 100,
  //   showOverflowTooltip: false,
  //   fixed: 'right',
  // },
]);

/** 表格搜索表单 */
export const tableSearchFormItems = (t: (msg:string)=>string) => ([
  {
    attrs: {
      label: '客户信息',
      prop: 'search_key',
    },
    value: {
      value: '',
      select: '1'
    },
    component: {
      is: 'f-input',
      props: {
        placeholder: '请输入客户信息',
        selectOptions: {
          props: {
            style: {
              width: '80px',
            }
          },
          options: [
            {
              label: '精确',
              value: '1',
            },
            {
              label: '模糊',
              value: '2',
            },
          ],
        },
      },
    },
  },
  {
    attrs: {
      label: '手机号',
      prop: 'mobile',
    },
    value: '',
    component: {
      is: 'el-input',
      props: {
        placeholder: '请输入手机号',
      },
    },
  },
  {
    attrs: {
      label: '标签',
      prop: 'tag_ids',
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请输入标签',
        filterable: true
      },
    },
  },
  {
    attrs: {
      label: '归属门店',
      prop: 'store_id', 
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请输入归属门店',
        filterable: true
      },
    },
    childrenComponent: {
      is: 'el-option',
      children:[]
    },
  },
  {
    attrs: {
      label: '到课次数',
      prop: 'daoke_times', 
    },
    value: [],
    component: {
      is: 'f-input-range',
    },
  },
  {
    attrs: {
      label: '完课次数',
      prop: 'wanke_times', 
    },
    value: [],
    component: {
      is: 'f-input-range',
    },
  },
  {
    attrs: {
      label: '红包次数',
      prop: 'hongbao_times', 
    },
    value: [],
    component: {
      is: 'f-input-range',
    },
  },
  {
    attrs: {
      label: '红包金额',
      prop: 'money', 
    },
    value: [],
    component: {
      is: 'f-input-range',
    },
  },
  {
    attrs: {
      label: '积分',
      prop: 'jifen', 
    },
    value: [],
    component: {
      is: 'f-input-range',
    },
  },
  {
    attrs: {
      label: '分享次数',
      prop: 'share_times', 
    },
    value: [],
    component: {
      is: 'f-input-range',
    },
  },
  {
    attrs: {
      label: '注册时间',
      prop: 'reg_time', 
    },
    value: '',
    component: {
      is: 'el-date-picker',
      
      props: {
        type: "datetimerange",
        startPlaceholder: t('search.date.start.placeholder'),
        endPlaceholder: t('search.date.end.placeholder'),
        defaultTime: [
          new Date(2000, 1, 1, 0, 0, 0),
          new Date(2000, 2, 1, 23, 59, 59),
        ],
        valueFormat: 'x',
        shortcuts: [
          {
            text: t('search.date.shortcuts0'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              // start.setDate(start.getDate() - 7)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts1'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setDate(start.getDate() - 7)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts2'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setMonth(start.getMonth() - 1)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts3'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setMonth(start.getMonth() - 3)
              return [start, end]
            },
          },
        ]
      },
    },
  },
  {
    attrs: {
      label: '加群状态',
      prop: 'qun_status', 
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请输入加群状态',
      },
    },
    childrenComponent: {
      is: 'el-option',
      children:() => [
        {
          label: '已加群',
          value: 1,
        },
        {
          label: '未加群',
          value: 2,
        },
      ],
    },
    
  },
  {
    attrs: {
      label: '好友状态',
      prop: 'friend_status', 
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请输入加好友状态',
      },
    },
    childrenComponent: {
      is: 'el-option',
      children:() => [
        {
          label: '已加好友',
          value: 1,
        },
        {
          label: '未加好友',
          value: 2,
        },
      ],
    },
  },
  {
    attrs: {
      label: '用户等级',
      prop: 'level_id', 
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请输入用户等级',
      },
    },
    childrenComponent: {
      is: 'el-option',
      children:[]
    },
  },
]);
